package com.mfangsoft.zhuangjialong.integration.fileupload.controller;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.mfangsoft.zhuangjialong.common.model.ResponseMessage;
import com.mfangsoft.zhuangjialong.common.utils.SysConstant;
import com.mfangsoft.zhuangjialong.integration.fileupload.service.FileUploadService;

@Controller("aaa")
@RequestMapping("/server")
public class FileUploadController {
	
	@Autowired
	private FileUploadService fileUploadServiceImpl;
	/**
	 * 判断是否是第一次上传
	 */
	@RequestMapping(value = "/selectIsFirstUpload", method = RequestMethod.GET)
	@ResponseBody
	@CrossOrigin
	public ResponseMessage<Map<String,Object>> isFirstUpload() {
		ResponseMessage<Map<String,Object>> message = new ResponseMessage<Map<String,Object>>();
		try {
			Map<String,Object> list = fileUploadServiceImpl.selectIsFirstUpload();
			message.setCode(SysConstant.SUCCESS_CODE);
			message.setMessage(SysConstant.SUCCESS_MSG);
			message.setResult(list);
		} catch (Exception e) {
			message.setCode(SysConstant.FAILURE_CODE);
			message.setMessage(SysConstant.FAILURE_MSG);
			e.printStackTrace();
		}
		return message;
	}
	
	/**
	 * 集团界面管理两个模板路径的入库
	 */
	@RequestMapping(value = "/insertInterfaceManagementTemplateUrl", method = RequestMethod.POST)
	@ResponseBody
	@CrossOrigin
	public ResponseMessage<Map<String,Object>> insertInterfaceManagementTemplateUrl(@RequestBody Map<String,Object> map) {
		ResponseMessage<Map<String,Object>> message = new ResponseMessage<Map<String,Object>>();
		try {
			fileUploadServiceImpl.insertInterfaceManagementTemplateUrl(map);
			message.setCode(SysConstant.SUCCESS_CODE);
			message.setMessage(SysConstant.SUCCESS_MSG);
		} catch (Exception e) {
			message.setCode(SysConstant.FAILURE_CODE);
			message.setMessage(SysConstant.FAILURE_MSG);
			e.printStackTrace();
		}
		return message;
	}
}
